package com.lyz.staticdemo;

/**
 * @ClassName D7_Test
 * @Description 测试单例模式
 * @Author 2214361854
 * @Date 2022/2/17 23:38
 * @Version 1.0
 */
public class D7_Test {
    public static void main(String[] args) {
        //饿汉式单例模式测试
        D7_SingleInstance es1 = D7_SingleInstance.instance;
        D7_SingleInstance es2 = D7_SingleInstance.instance;
        System.out.println(es1);
        System.out.println(es2);
        System.out.println(es1==es2);

        //懒汉式单例模式测试
        D7_SingleInstance2 ls1 = D7_SingleInstance2.getInstance();
        D7_SingleInstance2 ls2 = D7_SingleInstance2.getInstance();
        System.out.println(ls1);
        System.out.println(ls2);
        System.out.println(ls1==ls2);
    }
}
